package com.alibaba.sdk.controller;

import com.alibaba.sdk.model.OperationResult;
import com.alibaba.sdk.model.input.LoginInput;
import com.alibaba.sdk.model.output.LoginResponse;
import com.alibaba.sdk.service.LoginAndOutService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 用户登入登出接口
 *
 * @ writer Shawn(Shawn_0217@163.com)
 * @ date & time 2021/4/26 22:59
 * @ company alibaba
 */
@Api(tags = "用户登入登出接口")
@RestController
public class LoginAndOutController {

    @Resource
    private LoginAndOutService loginAndOutService;

    /**
     * 用户登入
     *
     * @param input 登入参数类
     * @return
     */
    @ApiOperation("用户登入")
    @PostMapping("/login")
    public OperationResult<LoginResponse> login(@Valid @RequestBody LoginInput input) {
        return loginAndOutService.login(input);
    }

    /**
     * 用户登出
     *
     * @return
     */
    @ApiOperation("用户登出")
    @PostMapping("/logout")
    public OperationResult logout() {
        return loginAndOutService.logout();
    }
}
